package com.example.reviewdemo.index;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;

import com.example.reviewdemo.MainActivity;
import com.example.reviewdemo.R;

public class SplashActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splash);

        goIndex();
    }

    private void goIndex() {
        // 在其他页面或应用重新启动时检查登录状态
        SharedPreferences sharedPreferences = getSharedPreferences("loginPrefs", Context.MODE_PRIVATE);
        boolean isLoggedIn = sharedPreferences.getBoolean("isLoggedIn", false);
        if (isLoggedIn) {
            // 用户已登录，执行相应逻辑
            startActivity(new Intent(SplashActivity.this, MainActivity.class));

        } else {
            // 用户未登录，执行相应逻辑
            startActivity(new Intent(SplashActivity.this, IndexActivity.class));
            finish();
        }


    }


}